package com.five.community.service.impl;

import com.five.community.mapper.CarMapper;
import com.five.community.service.CarService;
import com.five.community.bean.Car;
import com.five.community.bean.vo.CarVo;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CarServiceImpl implements CarService {
    @Autowired
    private CarMapper carMapper;
    @Override
    public List<CarVo> selectAllCar() throws Exception {
        return carMapper.selectAllCar();
    }

    @Override
    public void insert(Car car) throws Exception {
        carMapper.insert(car);
    }

    @Override
    public void deleteById(long id) throws Exception {
        carMapper.delete(id);
    }

    @Override
    public List<CarVo> selectByName(String name) throws Exception {
        return carMapper.selectByName(name);
    }

    @Override
    public Car selectById(long id) throws Exception {
        return carMapper.selectById(id);
    }

    @Override
    public void update(Car car) throws Exception {
       carMapper.update(car);
    }

    @Override
    public List<CarVo> selectAllCars(Integer pageNum, Integer pageSize) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return carMapper.selectAllCar();
    }

    @Override
    public List<CarVo> selectAllByName(Integer pageNum, Integer pageSize, String name) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return carMapper.selectByName(name);
    }
}
